// 空海派下单接口
import request from '@/utils/request'

// 创建订单
export const createOrder = function (data) {
  return request({
    url: 'system/order/info',
    method: 'post',
    data,
  })
}

// 运世达标签
export const getYsdLabels = function (data) {
  return request({
    url: 'system/ysdApi/info/getYsdLabels',
    method: 'post',
    data,
  })
}

// 运世达轨迹查询
export const queryYsdTracking = function (data) {
  return request({
    url: 'system/ysdApi/info/queryYsdTracking',
    method: 'post',
    data,
  })
}

// 运世达推送确认
export const ysdCreateOrder = function (data) {
  return request({
    url: 'system/ysdApi/info/ysdCreateOrder',
    method: 'post',
    data,
  })
}
// 上传POD
export const uploadPOD = function (data) {
  return request({
    url: 'system/order/info/uploadPOD',
    method: 'post',
    data,
  })
}
// 查询POD
export const getUploadPOD = function (params) {
  return request({
    url: 'system/order/info/selectPod',
    params,
  })
}
// 下载发票
export function uploadInvoices(data) {
  return request({
    url: 'system/order/info/downloadInvoiceOrderFile',
    method: 'post',
    data,
  })
}
// 获取客户列表
export const getCustomerName = function (params) {
  return request({
    url: 'system/clinetManger/info/list',
    method: 'get',
    params,
  })
}

// 强制制单
export const forcePlaceOrder = function (data) {
  return request({
    url: `system/order/info/compelPrint/${ data }`,
    method: 'delete',
  })
}
// 新增产品
export const addProduct = function (data) {
  return request({
    url: 'system/products/info',
    method: 'post',
    data,
  })
}
// 签入
export const editOrderStatus = function (data) {
  return request({
    url: 'system/order/info/editOrderStatus/1',
    method: 'post',
    data,
  })
}
// 已派送
export const delivered = function ({ data, state }) {
  return request({
    url: `system/order/info/editOrderStatus/${ state }`,
    method: 'post',
    data,
  })
}
// 获取产品详情
export const getProductInfo = function (id) {
  return request({
    url: `system/products/info/${ id }`,
    method: 'get',
  })
}
// 更新产品
export const updateProduct = function (data) {
  return request({
    url: 'system/products/info',
    method: 'put',
    data,
  })
}
// 删除产品
export const deleteProduct = function (ids) {
  return request({
    url: `system/products/info/${ ids }`,
    method: 'delete',
  })
}

// 订单列表
export const getOrderList = function (params) {
  return request({
    url: 'system/order/info/listTable',
    method: 'get',
    params,
  })
}
// 新订单列表
export const getlistOrder = function (params) {
  return request({
    url: 'order/order/info/listOrder',
    method: 'get',
    params,
		
  })
}
// 工作流单多票订单列表
export const modifyUnitPrice = function (params) {
  return request({
    url: '/system/order/info/modifyUnitPrice',
    method: 'get',
    params,
  })
}

// 获取订单详情
export const getOrderInfo = function (id) {
  return request({
    url: `system/order/info/${ id }`,
    method: 'get',
  })
}

// 修改订单详情
export const updateOrderInfo = function (data) {
  return request({
    url: 'system/order/info',
    method: 'put',
    data,
  })
}

// 订单删除
export const deleteOrder = function (ids, data) {
  return request({
    url: `system/order/info/${ ids }`,
    method: 'delete',
    data,
  })
}

// 打标签
export const printLabel = function (data) {
  return request({
    url: '/system/printLabel/barCode',
    method: 'post',
    data,
  })
}

export const fedexOrderNo = function (orderNo) {
  return request({
    url: `system/fedex/fedexTrack/${ orderNo }`,
    method: 'post',
  })
}
// 修改中的图片删除
export const delOrderImg = function (data) {
  return request({
    url: `system/order/info/delGoodsImages/${ data.orderNo }`,
    method: 'post',
    data: { fileName: data.fileName },
  })
}

// 附加费管理 获取
export const getReceivable = function (params) {
  return request({
    url: '/system/receivableDetails/list',
    method: 'get',
    params,
  })
}
// 附加费管理 改
export const editReceivable = function (data) {
  return request({
    url: '/system/receivableDetails/edit',
    method: 'post',
    data,
  })
}
// 附加费管理 删
export const delReceivable = function (data) {
  const { ids, orderNo, remarks } = data
  return request({
    url: `system/receivable/${ ids }`,
    method: 'delete',
    data: { orderNo, remarks },
  })
}

// 获取应收费用类别
export const getSurchargeInfo = function () {
  return request({
    url: 'system/feeType/surchargeInfo',
    method: 'get',
  })
}
// 新 获取应收费用类别
export const getFeeTypeList = function () {
  return request({
    url: 'system/feeType/feeTypeList',
    method: 'get',
  })
}
// 附加费管理 详情
export const getReceivableDetail = function (id) {
  return request({
    url: `system/receivable/${ id }`,
    method: 'get',
  })
}

// ups手动跟踪管理
export const getUpsSerachTracking = function (data) {
  return request({
    url: 'system/ups/serachTracking',
    method: 'post',
    data,
    timeout: 1000 * 60 * 60 * 12,
  })
}

// ups手动跟踪管理2
export const getUpsSerachTrackingAdmin = function (data) {
  return request({
    url: 'system/ups/serachTrackingAdmin',
    method: 'post',
    data,
    timeout: 1000 * 60 * 60 * 12,
  })
}

// fedex手动跟踪管理
export const getFedexSerachTracking = function (data) {
  return request({
    url: 'system/fedex/fedexTrack',
    method: 'post',
    data,
    timeout: 1000 * 60 * 60 * 12,
  })
}
// 海外仓撤单
export const delOrderTerminalInfo = function (params) {
  const { id, ...data } = params
  return request({
    url: `system/orderTerminalInfo/${ id } `,
    method: 'delete',
    data,
  })
}
// 打单初始化包裹信息
export const initPackageInfo = function (orderNo) {
  return request({
    url: `system/ups/initPackageInfo/${ orderNo }`,
    method: 'post',
  })
}

// 订单详情接口
export const getOrderDetail = function (id) {
  return request({
    url: `system/order/info/${ id }`,
    method: 'get',
  })
}

// 偏远邮编查询
export const getPostcode = function (params) {
  return request({
    url: 'system/postcode/list',
    params,
  })
}

export const searchPostalCodeByCity = function (params) {
  return request({
    url: 'system/recipientCode/searchPostalCodeByCity',
    params,
  })
}

export const searchPostalCodeByState = function (params) {
  return request({
    url: 'system/recipientCode/searchPostalCodeByState',
    params,
  })
}

export const getUserList = function (params) {
  return request({
    url: `system/user/selectUsernameByDeptId?deptId=${ params }`,
    method: 'get',
  })
}

export const getUserListTab = function () {
  return request({
    url: 'system/user/listTable',
  })
}

export const fasteners = function (orderNo) {
  return request({
    url: `system/order/info/fasteners/${ orderNo }`,
  })
}

export const track = function (data) {
  return request({
    url: 'system/track',
    method: 'put',
    data,
  })
}
// 刷新按钮
export const getRefresh = function (params) {
  return request({
    url: 'system/tagInfo/list',
    params,
  })
}

// 打印面单
export const tagInfo = function (data) {
  return request({
    url: '/system/tagInfo/downLoadTag',
    method: 'post',
    data,
  })
}

// 打印卡派面单
export const getEmsOrderNO = function (data) {
  return request({
    url: '/system/ems/getEmsOrderNO',
    method: 'post',
    data,
  })
}
// 卡派轨迹新增
export const pushEmsTrack = function (data) {
  return request({
    url: '/system/ems/pushEmsTrack',
    method: 'post',
    data,
  })
}
// 卡派轨迹列表
export const getEmsTrackList = function (params) {
  return request({
    url: '/system/ems/pushEmsTrack',
    params,
  })
}
// 卡派轨迹修改
export const editEmsTrack = function (data) {
  return request({
    url: '/system/ems/pushEmsTrack',
    method: 'put',
    data,
  })
}
// 卡派轨迹详情
export const emsTrackDetail = function (data) {
  return request({
    url: '/system/ems/pushEmsTrack',
    method: 'put',
    data,
  })
}

// 卡派轨迹详情
export const editOrderInfo = function (data) {
  return request({
    url: '/system/order/info/editOrderInfo',
    method: 'put',
    data,
  })
}

// 批量修改价格
export const editPrice = function (data) {
  return request({
    url: 'system/order/info/batchUpdateUnitPrice',
    method: 'post',
    data,
  })
}

// 高级修改订单状态
export const updateOrderStatus = function (params) {
  return request({
    url: '/system/order/info/updateOrderStatus',
    method: 'get',
    params,
  })
}

// 创建外部渠道订单
export const createExternalOrder = function (data) {
  return request({
    url: 'system/externalChannels',
    method: 'post',
    data,
  })
}

// 外部渠道 start
// 获取表格
export const getExternalTable = function (params) {
  return request({
    url: 'system/externalChannels/listOrder',
    method: 'get',
    params,
  })
}
// 详情内修改
export const editOrderDetailInfo = function (data) {
  return request({
    url: '/system/externalChannels/editOrderInfo',
    method: 'put',
    data,
  })
}
// 修改
export const editupdateOrderInfo = function (data) {
  return request({
    url: 'system/externalChannels/editOrder',
    method: 'put',
    data,
  })
}
// 订单删除
export const deleteExternalOrder = function (ids, data) {
  return request({
    url: `system/order/info/${ ids }`,
    method: 'delete',
    data,
  })
}

// 修改页面数据获取
// export const getdetails(orderNo) {
//   return request({
//     url: `system/fedex/fedexTrack/${orderNo}`,
//     method: "post"
//   });
// }
// 外部渠道 end
// 新增转运订单
export const addTransfer = function (data) {
  return request({
    url: `/system/order/transshipment/addTransshipment/${ data.site }`,
    method: 'post',
    data,
  })
}
// 新的  新增转运订单
export const transfer = function (data) {
  return request({
    url: '/system/transfer',
    method: 'post',
    data,
  })
}

// yunShips查询订单信息
export const queryLabelsInfo = (params) => request({
  url: 'system/ups/queryLabelsInfo',
  params,
})
export const pickingIsComplete = (data) => request({
  url: 'system/order/info/pickingIsComplete',
  method: 'post',
  data,
})
